package andy.ham;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import android.support.v7.widget.RecyclerView;
import android.widget.TextView;


/**
 * Created by hy on 2018/6/19.
 */

public class searchDiaryAdapter extends RecyclerView.Adapter<searchDiaryAdapter.mViewHolder> {
    private List<Note> mDataList;
    private Context context;
    private int checkBox_Visibility;
    private ArrayList checkBoxList=new ArrayList();
    private String key;
    public interface ItemClickListener{
        void onItemClick(View view, int position, String lock);
        boolean onItemLongClick(View view,int position);
        void checkBoxClick(int position);
    }
    public ItemClickListener mListener;
    public void setOnItemClickListener(ItemClickListener listener){
        this.mListener=listener;
    }


    public searchDiaryAdapter(Context context, List<Note> list) {
        this.context=context;
        mDataList = list;
//        this.checkBox_Visibility=checkBox_Visibility;

    }

    public int getItemCount() {
        // 返回数据集合大小
        return mDataList == null ? 0 : mDataList.size();
    }

    public void onBindViewHolder(final mViewHolder holder, final int position) {
        TextView g_title,g_date;
        g_title=holder.title;
        g_date=holder.date;
        g_title.setText(mDataList.get(position).getTitle());
        g_date.setText(mDataList.get(position).getDate());
    }

    @Override
    public mViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new mViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.main_item, parent, false));
    }
    public class mViewHolder extends RecyclerView.ViewHolder {
        private TextView title;
        private TextView date;

        public mViewHolder(View itemView) {
            super(itemView);
            title=(TextView) itemView.findViewById(R.id.text1);
            date=(TextView) itemView.findViewById(R.id.created);

        }
    }
}
